package main

import (
	proto1 "OldPackageTest/d_gin_develop/ch06/proto"
	"fmt"
	"google.golang.org/protobuf/proto"
	"io"
	"net/http"
)

type rsp struct {
	ID     int64  `json:"id"`
	Result string `json:"result"`
	Error  string `json:"error"`
}

func main() {
	url := "http://127.0.0.1:8083/someProtoBuf"
	req, err := http.NewRequest("GET", url, nil)
	if err != nil {
		error.Error(err)
	}

	client := http.DefaultClient
	response, err := client.Do(req)
	if err != nil {
		error.Error(err)
	}

	fmt.Println(response)
	defer response.Body.Close()
	BodyData, err := io.ReadAll(response.Body)
	if err != nil {
		error.Error(err)
	}
	fmt.Println(BodyData)
	fmt.Println(string(BodyData))

	info := proto1.Teacher{}
	proto.Unmarshal(BodyData, &info)
	fmt.Println(info)
	fmt.Println(info.Name, info.Course)
}
